package md.mru.core.repositories;

import md.mru.core.domains.administration.Event;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

/**
 * @author sergiu.marin
 * @since 01.04.2014
 */
public interface EventRepository extends JpaRepository<Event, Long> {

    @Query("SELECT e FROM Event e WHERE not e.createdByUser.id=:userId AND e.createdByUser.userGroup.id=:groupId")
    Page<Event> loadNextEvents(@Param(value = "userId") long userId, @Param(value = "groupId") long groupId, Pageable request);

}
